package gui.ajuda;

import java.io.IOException;
import javax.microedition.lcdui.*;
import recados.Recados;

public class Ajuda extends List implements CommandListener {

    private final Command cmdVoltar;

    public Ajuda() {
        super("Ajuda", IMPLICIT);

        cmdVoltar = new Command("Voltar", Command.BACK, 0);

        try {
            append("Instruções", Image.createImage("/gui/ajuda/instrucoes.png"));
            append("Sobre", Image.createImage("/gui/ajuda/sobre.png"));
            append("Reportar Bug", Image.createImage("/gui/ajuda/bug.png"));
            append("Smiles", Image.createImage("/gui/ajuda/smileis.png"));
        } catch (IOException ex) {
        }

        addCommand(cmdVoltar);

        setCommandListener(this);
    }

    public void commandAction(Command c, Displayable d) {
        if (c == List.SELECT_COMMAND) {
            switch (getSelectedIndex()) {
                case 0:
                    Recados.getInstance().setCurrent(new Instrucoes());
                    break;
                case 1:
                    Recados.getInstance().setCurrent(new Sobre());
                    break;
                case 2:
                    Recados.getInstance().setCurrent(Recados.getInstance().getReportar());
                    break;
                case 3:
                    Recados.getInstance().setCurrent(new Smiles());
            }
        } else if (c == cmdVoltar) {
            if(Recados.getInstance().isLogado()){
                Recados.getInstance().setCurrent(Recados.getInstance().getPrincipal());
            }else{
                Recados.getInstance().setCurrent(Recados.getInstance().getUsuarios());
            }
        }
    }
}
